using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnlockCard : MonoBehaviour
{
    public List<GameObject> cards;
    public CardManager manager;
    private bool trigger = false;
    public int unlockeNumber;
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.tag == "Player" && trigger == false)
        {
            manager.IsThrowMode_able[unlockeNumber - 1] = true;
            AudioManager.instance.PlayShort(0);
            foreach(var card in cards)
            {
                card.SetActive(true);
            }
            trigger = true;
            StartCoroutine(DeleteObject());
        }

    }

    IEnumerator DeleteObject()
    {
        SpriteRenderer sp = GetComponent<SpriteRenderer>();
        float time = 0f;
        while (time < 1f)
        {
            time += Time.deltaTime;
            sp.color = new Color(sp.color.r, sp.color.g, sp.color.b, sp.color.a * (1 - time));
            yield return null;
        }
        gameObject.SetActive(false);
    }
}
